package com.hyts.dbutils.bean.jdbc;
import com.hyts.dbutils.config.JdbcConfig;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * project-name:coffice-toolbox
 * package-name:com.hyts.dbopera.dbutils.domain
 * author:Libo/Alex
 * create-date:2019-06-23 20:37
 * copyright:libo-hyts-github
 * email:libo2dev@aliyun.com
 * description:此类主要用于: sql执行对象的构建Bean数据对象
 */
@Accessors(chain = true)
public class JdbcParamBean<T> {

    /**
     * sql执行语句
     */
    @Getter
    @Setter
    private String sql;

    /**
     * sql执行传入参数
     */
    @Getter
    @Setter
    private T[][] params;

    /**
     * 自动断开链接close服务
     */
    @Getter
    @Setter
    private boolean autoClose;

    /**
     * 构造器
     * @param sql
     * @param params
     * @param autoClose
     */
    public JdbcParamBean(String sql, T[][] params, boolean autoClose) {
        this.sql = sql;
        this.params = params;
        this.autoClose = autoClose;
    }

    /**
     * 构造器
     * @param sql
     * @param params
     */
    public JdbcParamBean(String sql, T[][] params){
        this.sql = sql;
        this.params = params;
        this.autoClose = JdbcConfig.defaultJdbcAutocommit;
    }

    /**
     * 构造器
     * @param sql
     */
    public JdbcParamBean(String sql){
        this.sql = sql;
        this.params = null;
        this.autoClose = JdbcConfig.defaultJdbcAutocommit;
    }
}
